import AxiosIns from './axiosSetting'
let ajaxMethod = ['get', 'post'];
let api = {};
ajaxMethod.forEach((method) => {
  //数组取值的两种方式
  api[method] = function (uri, data) {
    var fd = new FormData();
    Object.keys(data).forEach(function (key) {
      fd.append(key, data[key])
    })
    return new Promise(function (resolve, reject) {
      AxiosIns[method](uri, fd).then(res => {
        if (!res.data.errCode) {
          resolve(res);
        }
      }).catch((response) => {})
    })
  }
});
export default api;
